#ifndef PROTREEWIDGET_H
#define PROTREEWIDGET_H

#include "protreethread.h"
#include "protreeitem.h"
#include "opentreethread.h"
#include "slideshowdlg.h"
#include <QTreeWidget>
#include <QSet>
#include <memory>
#include <QProgressDialog>
#include <QMediaPlayer>

class ProTreeWidget : public QTreeWidget
{
    Q_OBJECT;
public:
    ProTreeWidget(QWidget *parent = nullptr);
    void AddToTree(const QString &name ,const QString & path);
public slots:
    void SlotPreShow();
    void SlotNextShow();
    void SlotOpenPro(QString);
    void SlotSetMusic();
    void SlotStartMusic();
    void SlotStopMusic();
signals:
    void SigCancelProgress();
    void SigUpdateSelected(const QString&);
    void SigUpdatePic(const QString&);
    void SigClearSelected();
private slots:
    void SlotItemPressed(QTreeWidgetItem *pressedItem, int column);
    void SlotImport();
    void SlotUpdateProgress(int count);
    void SlotCancelProgress();
    void SlotFinishProgress();
    void SlotDoubleClickItem(QTreeWidgetItem *item, int column);
    void SlotFinishOpenProgress();
    void SlotUpOpenProgress(int count);
    void SlotClosePro();
    void SlotSetActive();
    void SlotSlideShow();
private:
    QSet<QString> _set_path;
    QAction * _action_import;
    QTreeWidgetItem* _right_btn_item;
    std::shared_ptr<ProTreeThread> _thread_create_pro;
    QProgressDialog *_dialog_progress;//进度条
    QTreeWidgetItem* _selected_item = nullptr;//双击的图片
    std::shared_ptr<OpenTreeThread> _thread_open_pro;
    QProgressDialog* _open_progressdlg;
    QAction *_action_setstart;
    QAction *_action_closepro;
    QAction *_action_slideshow;

    QTreeWidgetItem *_active_item;

    std::shared_ptr<SlideShowDlg> _slide_show_dlg;
    QMediaPlayer * _player;
    QStringList _musiclist;
    QAudioOutput *_audioOutput;//调节播放声音。
    int _currentIndex;//播放索引.
};

#endif // PROTREEWIDGET_H
